﻿using System.Text.RegularExpressions;

namespace net.xBei.Helper {
    /// <summary>
    /// 
    /// </summary>
    public static class WebSocketHelper {
                                              //ws{1,2}:\/\/[\.a-z0-9:]+?:\d{2,5}(\/.+)?
        static readonly Regex regLocation = new("^ws{1,2}:\\/\\/[\\.a-z0-9:]+?:\\d{2,5}(\\/.+)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
        /// <summary>
        /// 是否是有效的WebSocket连接地址
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public static bool IsWebSocketLocation(this string? location)
            => !string.IsNullOrWhiteSpace(location) && regLocation.IsMatch(location);
    }
}
